<template>
  <div class="box">
    <!-- 登录表单 -->
    <div class="scanBox">
      <!-- <div class="title">登录</div> -->
      <iframe
        frameborder="no"
        border="0"
        marginwidth="0"
        marginheight="0"
        scrolling="no"
        allowtransparency="yes"
        :src="wxLoginUrl"
        alt=""
        style="width:100%;height:340px"
      />
      <p class="tips">请使用微信扫描二维码登录</p>
      <div class="aColor">
        <router-link to="/toLogin">账号登录</router-link>
      </div>
    </div>
  </div>
</template>

<script>
import Vue from "vue";

export default {
  mounted () {

  },
  name: 'loginreg',
  components: {
  },
  data () {
    return {
      loginDialogVisible: true, // 登录框默认展示
      scanloginDialogVisible: false,
      regDialogVisible: false,
      activeIndex: '4',
      wxLoginUrl: 'https://open.weixin.qq.com/connect/qrconnect?appid=wx6097e280b049a71e&redirect_uri=http%3A%2F%2Fwww.go4nines.com%2Feaston%2FtoLogin&response_type=code&scope=snsapi_login&state=#wechat_redirect'

    }
  },
  methods: {
    getAccessToken () {

    },
    // 登录验证操作
    loginHandle () {
      this.$refs.loginFormRef.validate(async valid => {
        // 预校验登录数据不通过
        if (!valid) return
        // 预校验通过
        // 发送axio请求
        const { data: res } = await this.$http.post('login', this.loginForm)
        // 判断状态码
        if (res.status !== 200) {
          return this.$message.error(res.meta.msg)
        }
        // 登录成功
        this.$message.success('登录成功！')
        // 将 token 保存到本地
        // 浏览器在关闭以后，就需要删除 token，因此需要使用 sessionStorage
        window.sessionStorage.setItem('token', res.data.token)
        this.$router.push('/userinfo')
      })
    }
  }
}
</script>

<style lang="less" scoped>
.scanBox {
  width: 34.5rem;
  height: 34.5rem;
  padding: 0 5.9375rem;
  padding-top: 3.125rem;
  box-sizing: border-box;
  background-color: #fff;
  margin: auto;
  position: absolute;
  top: 6.25rem;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0px 0px 0.625rem 0px rgba(0, 0, 0, 0.5);
  border-radius: 0.3125rem;
  .title {
    font-size: 2rem;
    color: #999999;
    text-align: center;
    height: 8.0625rem;
    line-height: 8.0625rem;
  }
  .tips {
    margin-top: 1.0625rem;
    font-size: 1rem;
  }
  .aColor {
    text-align: center;
    margin: 2.8125rem 0;
    a {
      font-size: 1rem;
      color: #ff5e4e;
      text-decoration: underline;
    }
  }
}
.CodeBox {
  width: 17.5rem;
  height: 17.5rem;
  margin-left: 2.6875rem;
  border: 0.0625rem solid #eee;
  img {
    width: 100%;
    height: 100%;
  }
}
.tips {
  text-align: center;
  color: #999;
}
</style>
